package de.jmda.core.util.jpa;

public enum EntityRelation
{
	OneToOneUnidirectional,
	OneToOneBidirectional,
	OneToManyUnidirectional,
	OneToManyBidirectional,
	ManyToOneUnidirectional,
	ManyToOneBidirectional,
	ManyToManyUnidirectional,
	ManyToManyBidirectional;

	public static boolean isUnidirectional(EntityRelation entityRelation)
	{
		return
				((entityRelation == OneToOneUnidirectional  ) ||
				 (entityRelation == OneToManyUnidirectional ) ||
				 (entityRelation == ManyToOneUnidirectional ) ||
				 (entityRelation == ManyToManyUnidirectional)) == true;

	}

	public static boolean isBidirectional(EntityRelation entityRelation)
	{
		return isUnidirectional(entityRelation) == false;
	}

	public static boolean isOneToOne(EntityRelation entityRelation)
	{
		return
				((entityRelation == OneToOneUnidirectional) ||
				 (entityRelation == OneToOneBidirectional)) == true;
	}

	public static boolean isOneToMany(EntityRelation entityRelation)
	{
		return
				((entityRelation == OneToManyUnidirectional) ||
				 (entityRelation == OneToManyBidirectional)) == true;
	}

	public static boolean isManyToOne(EntityRelation entityRelation)
	{
		return ((entityRelation == ManyToOneUnidirectional) ||
		        (entityRelation == ManyToOneBidirectional))== true;
	}

	public static boolean isManyToMany(EntityRelation entityRelation)
	{
		return
				((entityRelation == ManyToManyUnidirectional) ||
				 (entityRelation == ManyToManyBidirectional)) == true;
	}

	public static boolean isToOne(EntityRelation entityRelation)
	{
		return (isOneToOne(entityRelation) || isManyToOne(entityRelation)) == true;
	}

	public static boolean isToMany(EntityRelation entityRelation)
	{
		return (isToOne(entityRelation)) == false;
	}
}